<script type="text/javascript">
	function doSearchTransAccount(value) {
		
	}
	
	//表格查询  
	function reloadTransAccount() {
		var params = transAccount_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		transAccount_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		transAccount_list.datagrid('unselectAll');
		transAccount_list.datagrid('uncheckAll');
	}


	function addTransAccount() {
		
		var rows = transAccount_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("账户设置信息", "transAccount.do?editTransAccount&transAccountId=" + rows[0].id,
					"transAccount.do?saveTransAccount", function(data) {
						reloadTransAccount();
					},true);
		} else {
			createFromWindow("账户设置信息", "transAccount.do?editTransAccount", "transAccount.do?saveTransAccount",
					function(data) {
						reloadTransAccount();
					});
		}
	}
	
	function deleteTransAccount() {
		var rows = transAccount_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('transAccount.do?deleteTransAccountItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadTransAccount();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editTransAccount() {
		var rows = transAccount_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "transAccount.do?editTransAccount&transAccountId=" + rows[0].id,
					"transAccount.do?saveTransAccount", function(data) {
						reloadTransAccount();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	function inTransAccount() {
		var rows = transAccount_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow(rows[0].accountName+"-资金入账操作", "transAccount.do?skip&page=inTransAccount&transAccountId=" + rows[0].id,
					"transAccountTrade.do?inTransAccount", function(data) {
						reloadTransAccount();
					},true,550,320);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	function outTransAccount() {
		var rows = transAccount_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow(rows[0].accountName+"-资金提取操作", "transAccount.do?skip&page=outTransAccount&transAccountId=" + rows[0].id,
					"transAccountTrade.do?outTransAccount", function(data) {
						reloadTransAccount();
					},true,550,320);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	function tradeTransAccount() {
		var rows = transAccount_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow(rows[0].accountName+"-交易记录", "transAccount.do?skip&page=tradeTransAccount&transAccountId=" + rows[0].id,
					"transAccount.do?saveTransAccount", function(data) {
						reloadTransAccount();
					},false,1000,600);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	
	//操作按钮触发
	function operationsLookTransAccount(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = transAccount_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "transAccount.do?editTransAccount&transAccountId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditTransAccount(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = transAccount_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "transAccount.do?editTransAccount&transAccountId=" + id,
					"transAccount.do?saveTransAccount", function(data) {
						reloadTransAccount();
					},true);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendTransAccount() {
		printLog('发送');
	}
	
	function operationsDeleteTransAccount(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('transAccount.do?deleteTransAccountItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadTransAccount(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function clearTransAccountSearch() {
		setGridSearchParams('transAccount_list','transAccountSearchForm',true,reloadTransAccount);
	}
	
	//根据条件查询
	function transAccountSearch() {
		setGridSearchParams('transAccount_list','transAccountSearchForm',false,reloadTransAccount);
	}
</script>

<#assign operations = "[\{shiro:'trans:transAccount:refresh',onClick:'operationsLookTransAccount',src:'static/jmax/images/notes/note.png',title:'查看'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="transAccount_list" toolbar="#transAccountlist_search" idField="id" operations="${operations!}"
			 url="transAccount.do?loadList" rownumbers="true"
			 item="com.xdtech.trans.vo.TransAccountItem"/>
		
		<div id="transAccountlist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="transAccountSearchForm">
					<table>
						<tr>
							<td class="tbLabel">网点名称：</td>
							<td>
								<@eu.comboTree url="transWebSite.do?websiteTree" name="websiteId" multiple="false"/>
							</td>
							<td class="tbLabel">网点类型:</td>
							<td>
								<@eu.comboBox name="websiteType" url="common.do?loadComboBox&key=WEBSITE_TYPE"  />
							</td>
							<td class="tbLabel">账户类型:</td>
							<td>
								<@eu.comboBox name="accountType" url="common.do?loadComboBox&key=ACCOUNT_TYPE"  />
							</td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="transAccountSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearTransAccountSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="transAccount_toolbar" style="height: auto">
				<@eu.linkbutton showName="账户设置" shiro="trans:transAccount:set" iconCls="icon-add" onclick="addTransAccount()"/>
				<@eu.linkbutton showName="资金入账" shiro="trans:transAccount:in" iconCls="icon-remove" onclick="inTransAccount()"/>
				<@eu.linkbutton showName="资金提取" shiro="trans:transAccount:out" iconCls="icon-remove" onclick="outTransAccount()"/>
				<@eu.linkbutton showName="交易记录" shiro="trans:transAccount:tradeRecord" iconCls="icon-edit" onclick="tradeTransAccount()"/>
				<@eu.linkbutton showName="删除" shiro="trans:transAccount:delete" iconCls="icon-remove" onclick="deleteTransAccount()"/>
				<@eu.linkbutton showName="刷新" shiro="trans:transAccount:refresh" iconCls="icon-reload" onclick="reloadTransAccount()"/>
				
			</div>
		</div>
	</div>
</div>